package org.hxzon.workeasy.util;

import java.util.List;

import org.hxzon.util.EMailUtil.EMail;
import org.hxzon.workeasy.model.EasyTag;
import org.hxzon.workeasy.model.EasyUzer;
import org.hxzon.workeasy.model.base.Upload;

public class WorkEasyUtil {

    public static String toTagsString(List<EasyTag> tags) {
        StringBuilder sb = new StringBuilder();
        for (EasyTag tag : tags) {
            sb.append(",").append(tag);
        }
        return sb.toString();
    }

    public static String[] toTags(String tagString) {
        if (tagString == null || tagString.isEmpty()) {
            return new String[0];
        }
        String[] result = tagString.split(" ");
        return result;
    }

    public static String[] splitString(String origString) {
        if (origString == null || origString.isEmpty()) {
            return new String[0];
        }
        String[] result = origString.split(" ");
        return result;
    }

    public static EMail newEMail() {
        EMail email = new EMail();
        email.setHost("");
        email.setFrom("");
        email.setUsername("");
        email.setPassword("");
        email.setEncoding("UTF-8");
//		email.addCharset("charset=utf8");
//		email.addCharset("charset=gbk");
        return email;
    }

    //html

    //export info
    public static StringBuilder buildMessage(EasyUzer userInfo) {
//		overview+=userInfo.getUsername();
        StringBuilder message = new StringBuilder();
        message.append("用户名:").append(userInfo.getUsername()).append(";\n");
        message.append("用户等级:").append(userInfo.getAdminGrade()).append(";\n");
        return message;
    }

    public static StringBuilder buildMessage(Upload upload) {
        StringBuilder message = new StringBuilder();
        message.append("文件名：").append(upload.getFileName()).append(";\n");
        message.append("文件路径：").append(upload.getFilePath()).append(";\n");
        return message;
    }

}
